﻿@model Round

@{
    ViewBag.Title = "Resultat";
}

<div class="page-header">
    <h1><span class="glyphicon glyphicon-list"></span> @Model.Course.Name</h1>
</div>

<div class="panel panel-success">
    <div class="panel-heading"><h4>Scoreboard | @Model.DateEntry.ToLongDateString()</h4></div>
    <div class="panel-body">
        <p>@Model.Course.Name, @Model.Course.Address, @Model.Course.ZipCode&nbsp;@Model.Course.City</p>
    </div>
    <table class="table table-hover table-responsive">
        <thead>
            <tr>
                <th>#</th>
                <th>score</th>
                <th>spiller</th>
                <th>netto</th>
                <th>brutto</th>
                <th>stbl</th>
                <th>dkk</th>
            </tr>
        </thead>
        <tbody>
            @foreach (Scorecard sc in Model.Scorecards.OrderBy(s => s.PositionByNettoscore))
            {
                <tr>
                    <td>@sc.PositionByNettoscorePrintable</td>
                    <td>@sc.NettoScoreVersusParPrintable</td>
                    <td>
                        <a href="#" onclick="return toggleScorecard(@sc.Player.Id)">
                            @sc.Player.DisplayName
                        </a>
                    </td>
                    <td>@sc.NettoScore</td>
                    <td>@sc.Score</td>
                    <td>@sc.StablefordPoints</td>
                    <td>@sc.OrderOfMeritPoints</td>
                </tr>
                <tr id="@sc.Player.Id" style="display: none; font-size: 90%;">
                    <td colspan="7">
                            
                            <table class="table table-condensed scorecard">
                                <tr>
                                    <td colspan="40">
                                        <h5>
                                            @sc.Tee.Name
                                            @if (sc.Tee.Description != null)
                                            {
                                                <text>/</text> @sc.Tee.Description
                                            }
                                            <small><br />CR @sc.Tee.CR <text> / slope </text> @sc.Tee.Slope</small>
                                        </h5>
                                    </td>
                                </tr>
                                <tr>
                                    <td>hul</td>
                                    @for (int i = 1; i < 10; i++)
                                    {
                                        <td>@i</td>
                                    }
                                    <td><b>UD</b></td>
                                    @for (int i = 10; i < 19; i++)
                                    {
                                        <td>@i</td>
                                    }
                                    <td><b>IND</b></td>
                                    <td><b>I&nbsp;ALT</b></td>
                                </tr>
                                <tr class="score">
                                    <td>
                                        score <sup>putts</sup>
                                    </td>
                                    @for (int i = 1; i < 10; i++)
                                    {
                                        <td class="@sc.ScoreCssClass(i)">
                                            @sc.GetStrokesForHole(i) <sup>@sc.GetPuttsForHole(i)</sup>
                                        </td>
                                    }
                                    <td>
                                        <b>@sc.ScoreOut</b> <sup>@sc.PuttsOut</sup>
                                    </td>
                                    @for (int i = 10; i < 19; i++)
                                    {
                                        <td class="@sc.ScoreCssClass(i)">
                                            @sc.GetStrokesForHole(i) <sup>@sc.GetPuttsForHole(i)</sup>
                                        </td>
                                    }
                                    <td><b>@sc.ScoreIn</b> <sup>@sc.PuttsIn</sup></td>
                                    <td><b>@sc.Score</b> <sup>@sc.Putts</sup></td>
                                </tr>
                                <tr class="stbl">
                                    <td>
                                        <span class="hidden-xs hidden-sm">stableford point</span>
                                        <span class="hidden-md hidden-lg">stbl</span>
                                    </td>
                                    @for (int i = 1; i < 10; i++)
                                    {
                                        <td>@(sc.GetStablefordPoints(i) == 0 ? "-" : @sc.GetStablefordPoints(i).ToString())</td>
                                    }
                                    <td><b>@sc.StablefordPointsOut</b></td>
                                    @for (int i = 10; i < 19; i++)
                                    {
                                        <td>@(sc.GetStablefordPoints(i) == 0 ? "-" : @sc.GetStablefordPoints(i).ToString())</td>
                                    }
                                    <td><b>@sc.StablefordPointsIn</b></td>
                                    <td><b>@sc.StablefordPoints</b></td>
                                </tr>
                                <tr>
                                    <td>gir</td>
                                    @for (int i = 1; i < 10; i++)
                                    {
                                        <td>
                                            @if (sc.GIRForHole(i))
                                            { <span class="glyphicon glyphicon-asterisk"></span> }
                                        </td>
                                    }
                                    <td><b>@Math.Round(sc.GIROut / 9.0 * 100, 1)%</b></td>
                                    @for (int i = 10; i < 19; i++)
                                    {
                                        <td>
                                            @if (sc.GIRForHole(i))
                                            { <span class="glyphicon glyphicon-asterisk"></span> }
                                        </td>
                                    }
                                    <td><b>@Math.Round(sc.GIRIn / 9.0 * 100, 1)%</b></td>
                                    <td><b>@Math.Round(sc.GIRTotal / 18.0 * 100, 1)%</b></td>
                                </tr>
                                <tr>
                                    <td>par</td>
                                    <td>@sc.Tee.Par1</td>
                                    <td>@sc.Tee.Par2</td>
                                    <td>@sc.Tee.Par3</td>
                                    <td>@sc.Tee.Par4</td>
                                    <td>@sc.Tee.Par5</td>
                                    <td>@sc.Tee.Par6</td>
                                    <td>@sc.Tee.Par7</td>
                                    <td>@sc.Tee.Par8</td>
                                    <td>@sc.Tee.Par9</td>
                                    <td>@sc.Tee.ParOut</td>
                                    <td>@sc.Tee.Par10</td>
                                    <td>@sc.Tee.Par11</td>
                                    <td>@sc.Tee.Par12</td>
                                    <td>@sc.Tee.Par13</td>
                                    <td>@sc.Tee.Par14</td>
                                    <td>@sc.Tee.Par15</td>
                                    <td>@sc.Tee.Par16</td>
                                    <td>@sc.Tee.Par17</td>
                                    <td>@sc.Tee.Par18</td>
                                    <td>@sc.Tee.ParIn</td>
                                    <td>@sc.Tee.Par</td>
                                </tr>
                                @if (sc.Tee.L1 != null)
                                {
                                    <tr class="hidden-xs hidden-sm">
                                        <td>meter</td>
                                        <td>@sc.Tee.L1</td>
                                        <td>@sc.Tee.L2</td>
                                        <td>@sc.Tee.L3</td>
                                        <td>@sc.Tee.L4</td>
                                        <td>@sc.Tee.L5</td>
                                        <td>@sc.Tee.L6</td>
                                        <td>@sc.Tee.L7</td>
                                        <td>@sc.Tee.L8</td>
                                        <td>@sc.Tee.L9</td>
                                        <td><b>@sc.Tee.LengthOut</b></td>
                                        <td>@sc.Tee.L10</td>
                                        <td>@sc.Tee.L11</td>
                                        <td>@sc.Tee.L12</td>
                                        <td>@sc.Tee.L13</td>
                                        <td>@sc.Tee.L14</td>
                                        <td>@sc.Tee.L15</td>
                                        <td>@sc.Tee.L16</td>
                                        <td>@sc.Tee.L17</td>
                                        <td>@sc.Tee.L18</td>
                                        <td><b>@sc.Tee.LengthIn</b></td>
                                        <td><b>@sc.Tee.Length</b></td>
                                    </tr>
                                }
                            </table>
                            <div>
                                <small>Point tjent: <b>@sc.TrophyListPoints.ToString("n2")</b> &nbsp;|&nbsp; GIR: <b>@sc.GIRPercentage.ToString("n1")%</b> &nbsp;|&nbsp; Handicap: <b>@sc.Handicap.ToString("n1")</b> / SPH: <b>@sc.GetPlayingHcp()</b></small>
                            </div>
                            
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

@Html.Partial("_Comments", Model.Comments)


@section Scripts{
<script>
    /* Toggle display of scorecard in table */
    function toggleScorecard(id) {
        $("#" + id).toggle();
        return false;
    }
</script>
}